package cn.edu.neusoft.model.bean;

import cn.edu.neusoft.util.ImageDownloader;
import lombok.Data;

import java.io.IOException;

@Data
public class CarIO {
    private String id;
    private String devId;
    private String devChnId;
    private int devChnNum;
    private String devName;
    private String parkingCarColorStr;
    private String devChnName;
    private String carNum;
    private int carNumColor;
    private String carNumColorStr;
    private int carType;
    private String carTypeStr;
    private int carColor;
    private String carDirect;
    private String carDirectStr;
    private String carWayCode;
    private String capTime;
    private int carBrand;
    private String carImgUrl;
    private String carNumPic;
    private int recStat;
    private int saveFlag;
    private int dcCleanFlag;
    private int carInnerCategory;
    private int strobeState;
    private String capTimeStr;
    private String carColorStr;
    private String realCapturePicPath;
    private String originalPicPath;
    private String parkingLotCode;
    private String parkingLot;
    private String parkingLotLikeStr;
    private String ownerName;
    private String ownerCode;
    private String ownerId;
    private String parkingCarColor;
    private String parkingCarLogo;
    private String parkingCarType;
    private String departmentId;
    private String name;
    private String departmentName;
    private String tideName;
    private int carLicensePlateType;
    private String carLicensePlateTypeStr;

    public void setOriginalPicPath(String originalPicPath) {
        // System.out.println("=== [CarIO] Starting originalPicPath processing ===");
        // System.out.println("[DEBUG] Original originalPicPath: " + originalPicPath);
        
        String tempUrl = "https://172.17.20.106/evo-apigw" + originalPicPath;
        // System.out.println("[DEBUG] Constructed full URL: " + tempUrl);

        //下载到本地
        try {
            // System.out.println("[DEBUG] Calling ImageDownloader.processImage to process image...");
            this.originalPicPath = ImageDownloader.processImage(tempUrl);
            // System.out.println("[SUCCESS] Image processing successful, new URL: " + this.originalPicPath);
            // System.out.println("=== [CarIO] originalPicPath processing completed ===");
        } catch (IOException e) {
            // System.err.println("[ERROR] ==> CarIO image download failed <==");
            // System.err.println("[ERROR] Original path: " + originalPicPath);
            // System.err.println("[ERROR] Processing URL: " + tempUrl);
            // System.err.println("[ERROR] Exception message: " + e.getMessage());
            // e.printStackTrace();
            // 发生异常时保持原始路径
            this.originalPicPath = originalPicPath;
        }
    }
}
